package com.lt.schoolchat.model.vo;

import com.lt.schoolchat.model.entity.User;
import com.lt.schoolchat.model.mongo.Video;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

/**
 * @description:
 * @author: ~Teng~
 * @date: 2023/5/17 10:50
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class VideoVO implements Serializable {
    private String id;
    private Long userId; // 用户id
    private String userAvatar; //头像
    private String userName; //昵称

    private String picUrl; //封面
    private String videoUrl; //视频URL
    private String text; //发布视频时，传入的文字内容

    private Integer hasLiked; //是否已赞（1是，0否）
    private Integer likeCount; //点赞数量

    public static VideoVO init(User user, Video video) {
        VideoVO vo = new VideoVO();
        //copy用户属性
        BeanUtils.copyProperties(user, vo);
        //copy视频属性
        BeanUtils.copyProperties(video, vo);
        vo.setId(video.getId().toHexString());
        vo.setHasLiked(0);
        return vo;
    }
}
